<%-- 
    Document   : gerenciamento
    Created on : 11/09/2014, 20:30:35
    Author     : aluno
--%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<jsp:useBean id="user" class="Model.Usuario" scope="session"/>
<jsp:useBean id="users" class="java.util.ArrayList" scope="session"/>
<jsp:useBean id="recs" class="java.util.ArrayList" scope="session"/>
<jsp:useBean id="administrator" class="Model.Administrator"/>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="css/css.css">
        <title>Gerenciamento</title>
    </head>
    <body>
        <c:choose>
            <c:when test="${administrator.is_administrator(user)}">
                <h2>Usuários</h2>
                <table border="1">
                    <tr>
                        <td>Nome</td>
                        <td>Email</td>
                        <td>Telefone</td>
                        <td>Estado</td>
                        <td>Cidade</td>
                        <td>Senha</td>

                    </tr>
                    <tr>
                        <td><input id="search-name" name="search-name" placeholder="filtar por nome"></td>
                        <td><input id="search-email" name="search-email" placeholder="filtar por e-mail"></td>
                        <td><input id="search-telefone" name="search-telefone" placeholder="(XX)XXXXX-XXXXX"></td>
                        <td><select id="state" name="state" required>

                                <jsp:useBean id="states" class="Model.State"/>
                                <c:forEach var="state" items="${states.getUf()}">
                                    <option value="${state.getValue()}">${state.getValue()}</option>
                                </c:forEach>
                            </select>         
                        </td>
                        <td><input id="search-city" name="search-city" placeholder="filtar por cidade"></td>

                    </tr>
                    <c:forEach var="usuario" items="${users}">
                        <tr>
                            <td>${usuario.getName()} </td>
                            <td>${usuario.getLogin()} </td>
                            <td>${usuario.getPhone()} </td>
                            <td>${usuario.getState()} </td>
                            <td>${usuario.getCity()} </td>
                            <td>${usuario.getPassword()} </td>
                            <td><a href="ServletUsuario?opt=cad&edit=${usuario.getId()}">Editar</a></td>
                            <td><a href="ServletUsuario?opt=deletar&un=${usuario.getId()}">Excluir</a></td>
                        </tr>
                    </c:forEach>
                </table>
                <br>
                <h2>Receitas</h2>
                <table border="1">
                    <tr>
                        <td>Name</td>
                        <td>Categoria</td>
                        <td>Dicas</td>
                        <td>Ingredientes</td>
                        <td>Disponível</td>
                        <td>Média das notas</td>
                        <td>Tempo de preparo</td>
                        <td>Valor nutricional</td>

                    </tr>
                    <c:forEach var="receita" items="${recs}">


                        <tr>
                            <td>${receita.getName()} </td>
                            <td>${receita.getCategoria()} </td>
                            <td>${receita.getClue()} </td>
                            <td>${receita.getIngredientes()}</td>
                            <td>${receita.getStatus()}</td>
                            <td>${receita.getAvg()}</td>
                            <td>${receita.getTime()}</td>
                            <td>${receita.getVal_nutri()}</td>
                            <td><a href="ServletReceita?opt=detalhe&id=${receita.getId()}">Detalhes</a> </td>
                            <td><a href="ServletReceita?opt=deletar&rec=${receita.getId()}">Excluir</a> </td>

                        </tr>
                    </c:forEach>

                </table><br>
                <br><a href="ServletUsuario?opt=detalhes" style="margin-left: 300px;">Voltar</a><br>
            </c:when>
            <c:otherwise>

            </c:otherwise>
        </c:choose>     
    </body>
</html>
